﻿package peace.graphic.tween.easing
{

public class Easing 
{
	public static const IN:String = "in";
	public static const OUT:String = "out";
	public static const INOUT:String = "inout";
	
	private var type:String;
	
	public function Easing (type:String = IN) 
	{
		this.type = type;
	}
	
	public function getValue (t:uint, begin:Number, delta:Number, duration:uint):Number
	{
		if (type == IN)
			return easeIn(t, begin, delta, duration);	
		else if (type == OUT)
			return easeOut(t, begin, delta, duration);	
		else 
			return easeInOut(t, begin, delta, duration);	
	}
	
	/**
	 * to be overridden in subclasses:
	 * 
	 * @param time - текущее время
	 * @param begin - начальное
	 * @param delta - end - begin
	 * @param duration - длительность
	 */
	protected function easeIn (time:Number, begin:Number, delta:Number, duration:Number):Number {return 0;}
	protected function easeOut (time:Number, begin:Number, delta:Number, duration:Number):Number {return 0;}
	protected function easeInOut (time:Number, begin:Number, delta:Number, duration:Number):Number {return 0;}
	
}

}
